package cn.iocoder.yudao.module.crm.service.receivable.listener;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.mq.redis.core.stream.AbstractRedisStreamMessageListener;
import cn.iocoder.yudao.module.bpm.event.ReceivableBpmProcessInstanceStatus;
import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService;
import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
@Slf4j
public class CrmReceivableRedisConsumersListener extends AbstractRedisStreamMessageListener<ReceivableBpmProcessInstanceStatus> {

    @Resource
    private CrmReceivableService receivableService;

    @Override // 监听器
    public void onMessage(ReceivableBpmProcessInstanceStatus message) {
        if (!StrUtil.equals(message.getProcessDefinitionKey(), CrmReceivableServiceImpl.BPM_PROCESS_DEFINITION_KEY)) {
            log.info("[onMessage][消息内容({})]", message);
            return;
        }
        receivableService.updateReceivableAuditStatus(Long.parseLong(message.getBusinessKey()), message.getStatus());
    }

}
